package com.zc.utils;

import com.zc.utils.redisThread.RedisThread;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPubSub;

@Component
public class RedisMsgPubSub extends JedisPubSub {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public void unsubscribe() {
		super.unsubscribe();
	}

	@Override
	public void unsubscribe(String... channels) {
		super.unsubscribe(channels);
	}

	@Override
	public void subscribe(String... channels) {
		super.subscribe(channels);
	}

	@Override
	public void psubscribe(String... patterns) {
		super.psubscribe(patterns);
	}

	@Override
	public void punsubscribe() {
		super.punsubscribe();
	}

	@Override
	public void punsubscribe(String... patterns) {
		super.punsubscribe(patterns);
	}

	/*
	 * (non-Javadoc) channal订阅的频道 s robot开关 A 活跃度
	 */
	@Override
	public void onMessage(String channel, String message){
		logger.debug("channel:" + channel + " receives message :" + message);
		//具体操作的地方
		RedisThread ss = RedisThread.getInstance();
		ss.setContent(message);
		ss.run();

	}

	@Override
	public void onPMessage(String pattern, String channel, String message) {

	}

	@Override
	public void onSubscribe(String channel, int subscribedChannels) {
		// System.out.println("channel:" + channel + "is been subscribed:" +
		// subscribedChannels);
	}

	@Override
	public void onPUnsubscribe(String pattern, int subscribedChannels) {

	}

	@Override
	public void onPSubscribe(String pattern, int subscribedChannels) {

	}

	@Override
	public void onUnsubscribe(String channel, int subscribedChannels) {
		// System.out.println("channel:" + channel + "is been unsubscribed:" +
		// subscribedChannels);
	}
}
